package org.meb.speedway.web;

import java.io.Serializable;
import java.util.List;

import javax.annotation.PostConstruct;
import javax.enterprise.context.SessionScoped;
import javax.inject.Inject;
import javax.inject.Named;

import lombok.Getter;

import org.meb.speedway.bean.ImportService;
import org.meb.speedway.bean.SearchService;
import org.meb.speedway.model.registry.Team;
import org.meb.speedway.query.TeamQuery;

@Named
@SessionScoped
public class TeamsBean implements Serializable {

	private static final long serialVersionUID = 2002779987505633776L;

	@Inject
	private SearchService searchService;

	@Inject
	private ImportService importService;

	@Getter
	private List<Team> teams;
	@Getter
	private String log;

	@SuppressWarnings("unused")
	@PostConstruct
	private void initialize() {
		TeamQuery query = new TeamQuery();
		query.getSortOrder().asc("name");
		teams = searchService.find(query);
	}

	public void importEventTasks() {
		log = importService.importEventSources();
	}
}
